package org.apache.flink.runtime.rest.messages.json;

import java.io.IOException;

import org.apache.flink.api.common.ConsumerID;
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonParser;
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.DeserializationContext;
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.deser.std.StdDeserializer;

/** Json deserializer for {@link JobID}. */
public class JobIDDeserializer extends StdDeserializer<ConsumerID> {
    private static final long serialVersionUID = -130167416771003559L;

    protected JobIDDeserializer() {
        super(ConsumerID.class);
    }

    @Override
    public ConsumerID deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
        return ConsumerID.fromHexString(p.getValueAsString());
    }
}
